﻿@model IEnumerable<LibMS.Models.LibDocuments>
@{
    ViewBag.Title = "Quản lý tài liệu";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

@section CSS {
    <link href="~/Contents/Styles/Plugins/jasny-bootstrap/jasny-bootstrap.min.css" rel="stylesheet" />
}

@section Header {
    <div class="row">
        <div class="col-lg-12">
            <h1>Quản lý tài liệu <small>Thêm mới, cập nhật hoặc xóa tài liệu.</small></h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-cog home"></i>Quản trị</a></li>
                <li class="active"><i class="fa fa-pencil-square-o home"></i>Quản lý tài liệu</li>
            </ol>
        </div>
    </div>
}

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <div class="panel-title">
                    Danh sách tài liệu
                                <a id="addNew" href="#" class="btn btn-success btn-xs pull-right">Thêm mới</a>
                </div>
            </div>

            <div class="panel-body">
                <div class="row">
                    <div class="col-lg-4 pull-right">
                        <div class="input-group pull-right" style="margin-bottom: 20px;">
                            <input type="text" id="mainSearch" class="form-control" placeholder="Tìm kiếm tài liệu">
                            <span class="input-group-btn">
                                <button class="btn btn-default" type="button"><span class="glyphicon glyphicon-search"></span></button>
                            </span>
                        </div>
                    </div>
                </div>

                <table id="tableData" class="table table-striped">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Tài liệu</th>
                            <th>Ngày đăng</th>
                            <th>Danh mục</th>
                            <th>Tác giả</th>
                            <th>Số lượng</th>
                            <th>Lượt xem</th>
                            <th>Thao tác</th>
                        </tr>
                    </thead>
                    <tbody>
                        @if (Convert.ToBoolean(ViewData["success"]) == true)
                        {
                            for (int i = 0; i < Model.ToArray().Length; i++)
                            {
                            <tr>
                                <td>@(i + 1)</td>
                                <td>@Model.ToArray()[i].DocumentName</td>
                                <td>@String.Format("{0:dd/MM/yyyy}", Model.ToArray()[i].CreateDate.GetValueOrDefault(Convert.ToDateTime("01/01/2013")))</td>
                                <td>@Model.ToArray()[i].CategoryName</td>
                                <td>@Model.ToArray()[i].Author</td>
                                <td>@Model.ToArray()[i].Total</td>
                                <td>@Model.ToArray()[i].ViewCount</td>
                                <td>
                                    <button class="btn btn-default btn-xs table-action" value="@Model.ToArray()[i].DocumentId"><i class="fa fa-info-circle"></i></button>
                                    <button class="btn btn-default btn-xs table-action" value="@Model.ToArray()[i].DocumentId"><i class="fa fa-trash-o"></i></button>
                                    <button class="btn btn-default btn-xs table-action" value="@Model.ToArray()[i].DocumentId"><i class="fa fa-upload"></i></button>
                                    <button class="btn btn-default btn-xs table-action" value="@Model.ToArray()[i].DocumentId"><i class="fa fa-credit-card"></i></button>
                                </td>
                            </tr>
                            }
                        }
                    </tbody>
                </table>
            </div>

            <div class="panel-footer">
                <div class="text-right" style="margin: -20px 0 -24px;">
                    <div class="pull-left" style="margin: 20px 0 0;">
                        <h5><strong>Hiển thị: @(Model.ToArray().Length + "/" + ViewData["total"]) tài liệu</strong></h5>
                    </div>
                    <ul id="paging">
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Modal title</h4>
            </div>
            <div class="modal-body">
                <div id="myModal-alerts"></div>
                <!-- DocumentName-->
                <div class="form-group">
                    <label class="control-label" for="mdocumentName">Tên tài liệu</label>
                    <input type="text" class="form-control" id="mdocumentName" placeholder="Tên tài liệu">
                </div>

                <div class="row">
                    <div class="col-sm-6">
                        <!-- DocumentCategory-->
                        <div class="form-group">
                            <label class="control-label" for="mcategoryName">Danh mục</label>
                            <select class="form-control" id="mcategoryName">
                            </select>
                        </div>
                        <!-- KyHieu-->
                        <div class="form-group">
                            <label class="control-label" for="mkyHieu">Ký hiệu</label>
                            <input type="text" class="form-control" id="mkyHieu" placeholder="Ký hiệu" disabled>
                        </div>
                        <!-- DocumentAuthor-->
                        <div class="form-group">
                            <label class="control-label" for="mdocumentAuthor">Tác giả</label>
                            <input type="text" class="form-control" id="mdocumentAuthor" placeholder="Tác giả">
                        </div>
                        <!-- DocumentId-->
                        <div class="form-group">
                            <label class="control-label" for="mdocumentId">Id</label>
                            <input type="text" class="form-control" id="mdocumentId" disabled>
                        </div>
                        <!-- Thumbnail-->
                        <div class="form-group">
                            <label class="control-label" for="documentThumbnail">Ảnh đại diện</label>
                            <form id="documentThumbnail" method="post" enctype="multipart/form-data" action="/api/ApiLibDocuments/UploadThumbnail">
                                <div class="form-group">
                                    <div class="fileinput fileinput-new" data-provides="fileinput">
                                      <div class="fileinput-new thumbnail" style="width: 135px; height: 94px;">
                                      </div>
                                      <div class="fileinput-preview fileinput-exists thumbnail" style="width: 135px; height: 94px;"></div>
                                      <div>
                                        <span class="btn btn-default btn-file">
                                            <span class="fileinput-new">Chọn ảnh</span>
                                            <span class="fileinput-exists">Đổi ảnh</span>
                                            <input type="file" name="..." accept="image/jpeg" >
                                        </span>
                                        <a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput">Xóa ảnh</a>
                                      </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <!-- DocumentRack-->
                        <div class="form-group">
                            <label class="control-label" for="mdocumentRack">Rack</label>
                            <select class="form-control" id="mdocumentRack">
                            </select>
                        </div>
                        <!-- DocumentTotal-->
                        <div class="form-group">
                            <label class="control-label" for="mdocumentTotal">Số lượng</label>
                            <input type="text" class="form-control" id="mdocumentTotal" placeholder="Số lượng">
                        </div>
                        <!-- DocumentNXB-->
                        <div class="form-group">
                            <label class="control-label" for="mdocumentNXB">Nhà xuất bản</label>
                            <input type="text" class="form-control" id="mdocumentNXB" placeholder="Nhà xuất bản">
                        </div>
                        <!-- DocumentViewCount-->
                        <div class="form-group">
                            <label class="control-label" for="mdocumentViewCount">Lượt xem</label>
                            <input type="text" class="form-control" id="mdocumentViewCount" placeholder="Lượt xem" disabled>
                        </div>
                        <!-- DocumentDescription-->
                        <div class="form-group">
                            <label class="control-label" for="mdocumentDescription">Mô tả tài liệu</label>
                            <textarea rows="4" class="form-control" id="mdocumentDescription" placeholder="Mô tả tài liệu"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div id="myModalFooter" class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Hủy</button>
                <button type="button" class="btn btn-primary">Lưu dữ liệu</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>

<div class="modal fade" id="uploadModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="uploadModalLabel">Modal title</h4>
            </div>
            <div class="modal-body" id="uploadModalBody">
            </div>
            <div id="uploadModalFooter" class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Đóng lại</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->

@section JS {
    <script src="~/Scripts/Plugins/date.format.js"></script>
    <script src="~/Scripts/Plugins/jasny-bootstrap.min.js"></script>
    <script src="~/Scripts/Plugins/jquery.form.min.js"></script>
    <script src="~/Scripts/App/LibDocuments/AdminListDocument.js"></script>
    <script type="text/javascript">
        var total = @ViewData["total"];
        var adminListDocument = new AdminListDocument(total, 10, 1, 'CreateDate');
        adminListDocument.Init();
    </script>
}